<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('infoclass_list');
$id = isset($id) ? $id : '0';
	//权限验证
	if($cfg_adminlevel != 1)
	{
		//初始化参数
		$catgoryListPriv   = array();
		$catgoryAddPriv    = array();
		$catgoryUpdatePriv = array();
		$catgoryDelPriv    = array();

		$dosql->Execute("SELECT * FROM `#@__adminprivacy` WHERE `groupid`=".$cfg_adminlevel." AND `model`='category'");
		while($row = $dosql->GetArray())
		{
			//查看权限
			if($row['action'] == 'list')
				$catgoryListPriv[]   = $row['classid'];

			//添加权限
			if($row['action'] == 'add')
				$catgoryAddPriv[]    = $row['classid'];

			//修改权限
			if($row['action'] == 'update')
				$catgoryUpdatePriv[] = $row['classid'];

			//删除权限
			if($row['action'] == 'del')
				$catgoryDelPriv[]    = $row['classid'];

		}
	}


?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>栏目类别</title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/laymain.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
</head>
<body class="mainbody">
<form method="post" action="" id="form">
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>栏目类别</span>
   <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"></a>
      <div class="l-list">
        <ul class="icon-list">
          <?php if(IsModel('infoclass','add',1)) echo'<li><a class="add" href="infoclass_add.php?id='.$id.'"><i></i><span>新增</span></a></li>';?>
           <?php if(IsModel('infoclass','update',1)) echo'<li><a id="btnSave" class="save" href="javascript:UpOrderID(\'infoclass_save.php\');"><i></i><span>保存</span></a></li>';?>
          <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li>
		 <?php if(IsModel('infoclass','del',1)) echo'<li><a href="javascript:SubUrlParam(\'infoclass_save.php?action=delallclass\')" onclick="return ConfDelAll(1);" class="del"><i></i><span>删除</span></a></li>';?>
        </ul>
      </div>
    </div>
  </div>
</div>
<!--/工具栏-->

<!--列表-->
<div class="table-container">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="ltable">
	  <tr>
      <th width="5%">选择</th>
      <th width="5%">ID</th>
      <th align="left" >类别名称</th>
      <th width="8%">显示</th>
      <th align="left" width="65">排序</th>
      <th width="20%">操作</th>
    </tr>

	<?php
	function Show($id, $i=0)
	{
		global $dosql,$cfg_siteid,$cfg_adminlevel,
		       $catgoryListPriv,$catgoryAddPriv,
			   $catgoryUpdatePriv,$catgoryDelPriv;
			   
		$dosql->Execute("SELECT * FROM `#@__infoclass` WHERE `parentid`=$id and`siteid`='$cfg_siteid'  ORDER BY orderid,id ASC", $id);
		$i++;
	
		while($row = $dosql->GetArray($id))
		{	
			switch($row['infotype'])
			{
				case 0:
					$addurl   = 'info_update.php?id='.$row['id'];
					$infotype = ' <i title="栏目属于[单页]类型">[单页]</i>';
					break;  
				case 1:
					$addurl   = 'infolist_add.php?cid='.$row['id'];
					$infotype = ' <i title="栏目属于[列表]类型">[列表]</i>';
					break;
				case 4:
					$addurl   = 'goods_add.php?cid='.$row['id'];
					$infotype = ' <i title="栏目属于[商品]类型">[商品]</i>';
					break;
				default:
					$r = $dosql->GetOne("SELECT * FROM `#@__diymodel` WHERE `id`=".$row['infotype']);
					if(isset($r) && is_array($r))
					{
						$addurl   = 'modeldata_add.php?m='.$r['modelname'].'&cid='.$row['id'];
						$infotype = ' <i title="栏目属于['.$r['modeltitle'].']类型">['.$r['modeltitle'].']</i>';
					}
					else
					{
						$addurl   = 'javascript:;';
						$infotype = ' 没有获取到类型';
					}
			}
		//设置$classname
			$classname = '';
			//设置空格
			for($n = 1; $n < $i; $n++)
				$classname .= '&nbsp;&nbsp;';
			
			
		

			//添加权限
			if($cfg_adminlevel != 1)
			{
				if(in_array($row['id'], $catgoryAddPriv))
				{
					
					$addStr = '<a href="infoclass_add.php?infotype='.$row['infotype'].'&id='.$row['id'].'">添加子栏目</a>';
				}
				else
				{
					
					$addStr = '添加子栏目';
				}
			}
			else
			{	
				
				$addStr = '<a href="infoclass_add.php?infotype='.$row['infotype'].'&id='.$row['id'].'">添加子栏目</a>';
			}
			
			
			
			
			//修改权限
			if($cfg_adminlevel != 1)
			{
				if(in_array($row['id'], $catgoryUpdatePriv))
				{
					$updateStr = '<a href="infoclass_update.php?id='.$row['id'].'">修改</a>';
					$classname .= '<span class="folder-line"></span><span class="folder-open"></span>&nbsp;<a href="infoclass_update.php?id='.$row['id'].'">'.$row['classname'].'</a>';
				}
				else{
				$updateStr = '修改';
				$classname .= '<span class="folder-line"></span><span class="folder-open"></span>&nbsp;<span title="暂无修改权限哦~">'.$row['classname'].'</span>';
				}
			}
			else
			{	
				$classname .= '<span class="folder-line"></span><span class="folder-open"></span>&nbsp;<a href="infoclass_update.php?id='.$row['id'].'">'.$row['classname'].'</a>';
				$updateStr = '<a href="infoclass_update.php?id='.$row['id'].'">修改</a>';
			}

			//信息类型
			$classname .= '<span class="infoTypeTxt">'.$infotype.'</span>';
			
			//删除权限
			if($cfg_adminlevel != 1)
			{
				if(in_array($row['id'], $catgoryDelPriv))
					$delStr = '<a href="infoclass_save.php?action=delclass&cid='.$id.'&id='.$row['id'].'&classname='.$row['classname'].'" onclick="return ConfDel(2);">删除</a>';
				else
					$delStr = '删除';
			}
			else
			{
				$delStr = '<a href="infoclass_save.php?action=delclass&cid='.$id.'&id='.$row['id'].'&classname='.$row['classname'].'" onclick="return ConfDel(2);">删除</a>';
			}


			//审核状态
			switch($row['checkinfo'])
			{
				case 'true':
					$checkinfo = '显示';
					break;  
				case 'false':
					$checkinfo = '隐藏';
					break;
				default:
					$checkinfo = '没有获取到参数';
			}


			//审核权限
			if($cfg_adminlevel != 1)
			{
				if(in_array($row['id'], $catgoryUpdatePriv))
					$checkStr = '<a href="infoclass_save.php?action=check&id='.$row['id'].'&cid='.$id.'&checkinfo='.$row['checkinfo'].'" title="点击进行显示与隐藏操作">'.$checkinfo.'</a>';
				else
					$checkStr = $checkinfo;
			}
			else
			{
				$checkStr = '<a href="infoclass_save.php?action=check&id='.$row['id'].'&cid='.$id.'&checkinfo='.$row['checkinfo'].'" title="点击进行显示与隐藏操作">'.$checkinfo.'</a>';
			}

	
	?>

		
			<tr >
				<td align="center"><span class="checkall" style="vertical-align:middle;"><input type="checkbox" name="checkid[]" value="<?php echo $row['id']; ?>" /></span></td>
				<td align="center"><?php echo $row['id']; ?><input type="hidden"  name="id[]"id="id[]" value="<?php echo $row['id']; ?>" /></td>	
				<td ><?php echo $classname; ?></td>
				<td align="center"> <span><?php echo $checkStr; ?></span> </td>
				<td  align="center">
				<input type="text" name="orderid[]" id="orderid[]" class="sort" value="<?php echo $row['orderid']; ?>" />
				</td>
				<td align="center" style="white-space:nowrap;word-break:break-all;overflow:hidden;"><span><?php echo $addStr; ?></span> |<span><?php echo $updateStr; ?></span> | <span class="nb"><?php echo $delStr; ?></span></td>
			</tr>
	
	<?php
			Show($row['id'], $i+2);
		}
	}

	Show($id, $i=1);
	//判断无记录样式
	if($dosql->GetTotalRow($id) == 0 and $id<=0)
	{
		echo '<tr><td align="center" colspan="6">暂无记录</td></tr>';
	}
	

	?>
  	</table>
	<div class="pagelist">
	
	<div style="text-align:center;padding:10px;font-size:12px;color:#333">
	共有<span><?php if($id>0)echo $dosql->GetTotalRow($id) +1; else echo $dosql->GetTableRow('#@__infoclass',$cfg_siteid); ?></span>条记录</div>
	</div>
</div>
<!--/列表-->

</form>
</body>
</html>
